<template>
	<view class="">
		<das-ipt @SearchEvents="searchClick"></das-ipt>
		<view class="content">
			<view class="content-item" v-for="(i,index) in list" :key='index' @tap="$navTo('details?id='+i.id)">
				<image class="item-img" v-if="i.image.length>0" :src="i.image[0]" mode="aspectFit"></image>
				<image class="item-img" v-else src="../../static/word.png" mode="aspectFit"></image>
				<view class="item-content">
					<text class="content-title">{{i.course_name}}</text>
					<text class="content-time">{{i.createtime_text}}</text>
				</view>
			</view>
		</view>
		<das-add v-if="login != '协管员'" @func="$navTo('add')"></das-add>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				title: '',
				login: ''
			}
		},
		onShow() {
			this.init()
			this.login = uni.getStorageSync('login')
		},
		methods: {
			searchClick(e) {
				this.title = e
				this.init()
			},
			init() {
				let _this = this
				uni.request({
					url: this.$url + 'relevant.train_study/getTrainStudyList',
					method: 'GET',
					header: {
						token:uni.getStorageSync('token'),
						'content-type': 'application/json'
					},
					data: {
						title: this.title
					},
					success: (res) => {
						if (res.data.code == 1) {
							_this.list = res.data.data
							console.log(_this.list);
						}
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.content {
		padding: 0 23rpx;

		.content-item {
			padding: 16rpx 0;
			display: flex;
			align-items: center;
			border-bottom: 1rpx solid #DDDDDD;

			.item-img {
				width: 120rpx;
				height: 120rpx;
			}

			.item-content {
				display: flex;
				flex-direction: column;
				margin-left: 14rpx;

				.content-title {
					font-size: 30rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #333333;
				}

				.content-time {
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;
					margin-top: 12rpx;
				}
			}
		}
	}
</style>
